package org.example.controller;


import org.example.entity.User;
import org.example.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author example.demo
 * @since 2023-08-06
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    IUserService iUserService;
    @RequestMapping("login")
    User login(@RequestParam("userid") String userid,@RequestParam("password") String password){
        List<User> list=iUserService.lambdaQuery().eq(User::getUserid,userid).eq(User::getPassword,password).list();
        if(list.size()>0){
            return list.get(0);
        }
        else {
            User user=new User();
            user.setUserid("0");
            return user;
        }
    }

}
